chore(runway): cherry-pick fix(perps): enforce geo-block and compliance gate on Market Insights Long/Short actions#28688
Conversation
…Long/Short actions cp-7.72.1 (#28678) The `MarketInsightsView` (AI summaries page) Long/Short buttons navigated directly to `PerpsOrderRedirect` without checking geo-eligibility or running the compliance gate. This allowed users in restricted regions to bypass restrictions and open perps positions from the Market Insights entry point, even though every other entry point (Market Details, Order Book, Token Details) correctly blocked them. **Changes:** - Wrapped `handlePerpsDirectionPress` in the compliance `gate()` and added the `isEligible` geo-check before navigation, matching the pattern in `PerpsMarketDetailsView` and `AssetOverviewContent` - Renders the `PerpsBottomSheetTooltip` geo-block modal ("Perps unavailable in your region") when the user is ineligible - Added `MARKET_INSIGHTS` to `PERPS_EVENT_VALUE.SOURCE` for proper geo-block analytics attribution - Updated existing tests and added a new test case for the ineligible scenario CHANGELOG entry: Fixed a bug where users in restricted regions could open perps positions from the Market Insights page Fixes: ```gherkin Feature: Perps geo-block enforcement on Market Insights Scenario: Restricted user taps Long on Market Insights Given the user is in a geo-restricted region And the user navigates to Market Insights for a perps asset (e.g. ETH) When the user taps the "Long" button Then the "Perps unavailable in your region" modal is shown And the user is NOT navigated to the order screen Scenario: Restricted user taps Short on Market Insights Given the user is in a geo-restricted region And the user navigates to Market Insights for a perps asset When the user taps the "Short" button Then the "Perps unavailable in your region" modal is shown And the user is NOT navigated to the order screen Scenario: Eligible user taps Long on Market Insights Given the user is NOT in a geo-restricted region And the user navigates to Market Insights for a perps asset When the user taps the "Long" button Then the user is navigated to the order screen as expected ``` N/A — behavior matches existing geo-block modal shown on other Perps entry points. Tapping Long/Short on Market Insights in a restricted region navigated to the order screen (bypassing restrictions). <img width="1320" height="2868" alt="Simulator Screenshot - iPhone 17 Pro Max - 2026-04-10 at 17 46 41" src="https://github.com/user-attachments/assets/6d9e4b9f-2d69-4b4a-9bd2-13ee053bc26d" /> Tapping Long/Short on Market Insights in a restricted region shows the geo-block modal and blocks navigation. - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches Perps eligibility/compliance gating and navigation from `MarketInsightsView`, so mistakes could reintroduce a restriction bypass or block eligible users; changes are localized and covered by updated tests. > > **Overview** > Prevents the Market Insights Perps `Long`/`Short` CTAs from navigating directly to order flow without restrictions by wrapping the action in the compliance `gate()` and checking `selectPerpsEligibility` first. > > When ineligible, it now tracks a geo-block screen view with source `PERPS_EVENT_VALUE.SOURCE.MARKET_INSIGHTS` and shows the `PerpsBottomSheetTooltip` in a modal instead of navigating. Tests were updated to handle async gated presses and a new test asserts the ineligible geo-block behavior; the Perps view test renderer also ensures extra routes get the same Perps providers. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 8ed8908. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Javier Garcia Vera <javier.vera@consensys.net> Co-authored-by: javiergarciavera <76975121+javiergarciavera@users.noreply.github.com> Co-authored-by: Alejandro Garcia <alejandro.garcia@consensys.net> Co-authored-by: Nicholas Gambino <nicholas.gambino@consensys.net>
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
gambinish
left a comment
There was a problem hiding this comment.
Tested on Android and LGTM ✅
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
The changes are scoped to:
No changes to navigation infrastructure, Engine, controllers, or shared components that would affect other test suites (SmokeAccounts, SmokeIdentity, SmokeTrade, SmokeNetworkAbstractions, etc.). Performance Test Selection: |
|
|
✅ E2E Fixture Validation — Schema is up to date |



Description
The
MarketInsightsView(AI summaries page) Long/Short buttonsnavigated directly to
PerpsOrderRedirectwithout checkinggeo-eligibility or running the compliance gate. This allowed users in
restricted regions to bypass restrictions and open perps positions from
the Market Insights entry point, even though every other entry point
(Market Details, Order Book, Token Details) correctly blocked them.
Changes:
handlePerpsDirectionPressin the compliancegate()andadded the
isEligiblegeo-check before navigation, matching the patternin
PerpsMarketDetailsViewandAssetOverviewContentPerpsBottomSheetTooltipgeo-block modal ("Perpsunavailable in your region") when the user is ineligible
MARKET_INSIGHTStoPERPS_EVENT_VALUE.SOURCEfor propergeo-block analytics attribution
scenario
Changelog
CHANGELOG entry: Fixed a bug where users in restricted regions could
open perps positions from the Market Insights page
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
N/A — behavior matches existing geo-block modal shown on other Perps
entry points.
Before
Tapping Long/Short on Market Insights in a restricted region navigated
to the order screen (bypassing restrictions).
After
Tapping Long/Short on Market Insights in a restricted region shows the
geo-block modal and blocks navigation.
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Medium Risk
Touches Perps eligibility/compliance gating and navigation from
MarketInsightsView, so mistakes could reintroduce a restriction bypassor block eligible users; changes are localized and covered by updated
tests.
Overview
Prevents the Market Insights Perps
Long/ShortCTAs from navigatingdirectly to order flow without restrictions by wrapping the action in
the compliance
gate()and checkingselectPerpsEligibilityfirst.When ineligible, it now tracks a geo-block screen view with source
PERPS_EVENT_VALUE.SOURCE.MARKET_INSIGHTSand shows thePerpsBottomSheetTooltipin a modal instead of navigating. Tests wereupdated to handle async gated presses and a new test asserts the
ineligible geo-block behavior; the Perps view test renderer also ensures
extra routes get the same Perps providers.
Reviewed by Cursor Bugbot for commit
8ed8908. Bugbot is set up for automated
code reviews on this repo. Configure
here.
Co-authored-by: Javier Garcia Vera javier.vera@consensys.net
Co-authored-by: javiergarciavera 76975121+javiergarciavera@users.noreply.github.com
Co-authored-by: Alejandro Garcia alejandro.garcia@consensys.net
Co-authored-by: Nicholas Gambino nicholas.gambino@consensys.net 90f34c6